package main;

import java.awt.Graphics;
import javax.swing.JPanel;

/**
 *
 * @author Mark van der Wal
 */
public class DrawPanel extends JPanel
{
    //circle radius
    private int radius = 10;
    
    //current direction
    private float modX = 0;
    private float modY = 0;
    
    //current coordinates
    private float coordX;
    private float coordY;
            
    public void ModX(float modifier)
    {
        modX = modifier;
    }
    
    public void ModY(float modifier)
    {
        modY = modifier;
    }
    
    public DrawPanel()
    {
        
    }

    @Override
    public void setBounds(int i, int i1, int i2, int i3)
    {
        super.setBounds(i, i1, i2, i3);
        coordX = this.getWidth()/2;
        coordY = this.getHeight()/2;   
    }
    
    public void Update(float ms)
    {
        
        //update the content according to the current direction modifiers
        if(coordX + modX < this.getWidth()-radius &&
                coordX+modX > radius)
            coordX += modX;
        
        if(coordY + modY < this.getHeight()-radius &&
                coordY+modY > radius)
            coordY += modY;
        
        repaint();
    }
    
    @Override
    public void paintComponent(Graphics canvas)
    {
        super.paintComponent(canvas);
        
        //draw the amazing circle
        //canvas.drawOval((int)coordX-radius, (int)coordY-radius, radius*2, radius*2);
        canvas.fillOval((int)coordX-radius, (int)coordY-radius, radius*2, radius*2);
    }
}
